package excercise;

import java.util.Scanner;

public class EX03_Q35 {
	
	
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		System.out.println("고객님께서 낸 돈을 입력하세요");
		int a = sc.nextInt();
		
		System.out.println("계산할 금액을 입력하세요");
		int b = sc.nextInt();
		
		
		int c = a - b;
		
		int d = c / 50000;
		
		int e = (c - d * 50000) / 10000;
		
		int f = (c - d * 50000 - e * 10000) / 5000;
		
		int g = (c - d * 50000 - e * 10000 - f * 5000) / 1000;
		
		int h = (c - d * 50000 - e * 10000 - f * 5000 - g * 1000) / 500;
		
		int i = (c - d * 50000 - e * 10000 - f * 5000 - g * 1000 - h * 500) / 100;
		
		int j = (c - d * 50000 - e * 10000 - f * 5000 - g * 1000 - h * 500 - i * 100) / 50;
		
		int k = (c - d * 50000 - e * 10000 - f * 5000 - g * 1000 - h * 500 - i * 100 - j * 50) / 10;
		
		System.out.println();
		System.out.println("고객님께서 결제 하신후의 잔액은" + 
		(d * 50000 + e * 10000 + f * 5000 + g * 1000 + h * 500 + i * 100 + j * 50 + k * 10) );
		System.out.println("5만원짜리 " + d + "장");
		System.out.println("1만원짜리 " + e + "장");
		System.out.println("5천원짜리 " + f + "장");
		System.out.println("1천원짜리 " + g + "장");
		System.out.println("5백원짜리 " + h + "개");
		System.out.println("1백원짜리 " + i + "개");
		System.out.println("5십원짜리 " + j + "개");
		System.out.println("1십원짜리 " + k + "개");
		
		
		int money = sc.nextInt();
		int pay = sc.nextInt();
		int charge = money - pay;
		
		System.out.println("계산할 금액 : " + pay);
		System.out.println("지급액 : " + money);
		System.out.println("잔돈 : " + charge);
		
		int W50000 = 0, W10000 = 0, W5000 = 0, W1000 = 0, W500 = 0, W100 = 0, W50 = 0, W10 = 0;
		
		W50000 = charge / 50000;
		charge = charge % 50000;
		
		W10000 = charge / 10000;
		charge = charge % 10000;
		
		W5000 = charge / 5000;
		charge = charge % 5000;
		
		W1000 = charge / 1000;
		charge = charge % 1000;
		
		W500 = charge / 500;
		charge = charge % 500;
		
		W100 = charge / 100;
		charge = charge % 100;
		
		W50 = charge / 50;
		charge = charge % 50;
		
		W10 = charge / 10;
		charge = charge % 10;
		
		System.out.println("5만원권 : " + W50000);
		System.out.println("1만원권 : " + W10000);
		System.out.println("5천원권 : " + W5000);
		System.out.println("1천원권 : " + W1000);
		System.out.println("5백원짤 : " + W500);
		System.out.println("1백원짤 : " + W100);
		System.out.println("5십원짤 : " + W50);
		System.out.println("1십원짤 : " + W10);
		
		//반복문, 배열을 이용한 잔돈 처리
		
		int[] charges = {0,0,0,0,0,0,0,0,0};
		
		int[] moneys = {0, 50000, 10000, 5000, 1000, 500, 100, 50, 10};
		
		charge = money - pay;
		
		for(int z = 1; z <= 8; ++z){
			
			charges[z] = charge / moneys[z];
			
			charge = charge % moneys[z];
			
			System.out.println(moneys[z] + "/" + charges[z]);
			
		}
		
	}

}
